package project.layer.ant;

import project.layer.physical.Crossroad;
import framework.layer.agent.Agent;
import framework.utils.IdGenerator;

public abstract class Ant implements AntTickListener{
	protected Agent sendingAgent;
	private final int id;
	private Crossroad location;
	
	
	public Ant(Agent sendingAgent, Crossroad location ){
		this.id = IdGenerator.getIdGenerator().getNextId(Ant.class);
		this.location = location;
		this.sendingAgent = sendingAgent;
		AntLayer.getInstance().registerAnt(this);

	}
	
	@Override
	public abstract void processAntTick();
	
	public void die(){
		
		createDieEvent();
//		EventBroker.getEventBroker().notifyAll(new AntDiedEvent(this));
		AntLayer.getInstance().unregisterAnt(this);
	}
	protected abstract void createDieEvent();
	
	public Crossroad getLocation(){
		return location;
	}
	protected void setLocation(Crossroad location){
		this.location = location;
	}
	
	public int getId(){
		return id;
	}
	
	public abstract Agent getSendingAgent();
	
	
}
